<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>createElement</title>
</head>
<body>
<script type="text/javascript">
    var main = document.body;

    //创建链接--完善createa(url,text)创建链接函数，参数1为链接地址，参数2为链接文本。函数中添加链接地址、文本、文字颜色属性。
    function createa(url, text) {

        var a = document.createElement("a");
        //a.href="http://www.baidu.com";
        a.href = url;
        a.innerHTML = text;
        main.appendChild(a);
        document.write("<br>");

    }

    // 调用函数创建链接-，链接地址 http://www.imooc.com，文本为:慕课网
    createa("http://www.imooc.com", "慕课网");

    //练习
    //var body=document.body;
    var input = document.createElement("input");
    input.type = "button";
    input.value = "仅是按钮练习";
    main.appendChild(input);


</script>
</body>
</html>